package com.example.smartwaterapi.controller;

import com.example.smartwaterapi.common.api.RestApiResponse;
import com.example.smartwaterapi.entity.MonthlyStats;
import com.example.smartwaterapi.service.MonthlyStatsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 月度统计控制器
 */
@Tag(name = "月度统计管理API", description = "月度统计相关接口")
@RestController
@RequestMapping("/api/monthly-stats")
public class MonthlyStatsController {

    @Autowired
    private MonthlyStatsService monthlyStatsService;

    @Operation(summary = "获取月度统计详情", description = "根据ID获取月度统计信息")
    @GetMapping("/{id}")
    public RestApiResponse<MonthlyStats> getMonthlyStats(@Parameter(description = "ID") @PathVariable Long id) {
        MonthlyStats stats = monthlyStatsService.getById(id);
        if (stats == null) {
            return RestApiResponse.notFound("月度统计记录不存在");
        }
        return RestApiResponse.ok(stats);
    }

    // Add more endpoints

} 